package com.neusoft.race.sys.service.impl;
import java.util.List;
import java.util.Map;
import java.util.HashMap;

import javax.annotation.Resource;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neusoft.race.sys.bean.SysDictItem;
import com.neusoft.race.sys.mappers.SysDictItemMapper;
import com.neusoft.race.sys.service.ISysDictItemService;
import com.neusoft.utils.page.PageFactory;
@Service
@Transactional
public class SysDictItemServiceImpl  implements ISysDictItemService{
   @Resource
	private SysDictItemMapper sysDictItemMapper;
	@Override
	public   int deleteById(String id) {
		return sysDictItemMapper.deleteById(id);
	}

	@Override
	public int save(SysDictItem bean) {
		return sysDictItemMapper.insert(bean);
	}

	@Override
	public int updateById(SysDictItem bean) {
		return sysDictItemMapper.updateById(bean);
	}

	@Override
	public SysDictItem queryById(String id) {
		return sysDictItemMapper.queryById(id);
	}

	@Override
	public List<SysDictItem> queryList(Map<String, Object> param) {
		if(null==param){
			param= new HashMap<String, Object>();
		}
		if(null==param.get("isDelete")){
			param.put("isDelete",0);
		}
		return sysDictItemMapper.queryList(param);
	}

	@Override
	public Page<SysDictItem> queryPage(Map<String, Object> param, Pageable page) {
		if(null==param){
			param= new HashMap<String, Object>();
		}
		if(null==param.get("isDelete")){
			param.put("isDelete",0);
		}
		int count=sysDictItemMapper.queryPageCount(param);
		List<SysDictItem> list=sysDictItemMapper.queryPage(param, page);
		return PageFactory.createPage(list, page, count);
	}
	@Override
	public int saveOrUpdate(SysDictItem bean) {
		if(null==bean){
	     	return -1;
		}
		if(null!=bean.getId()){
		    return sysDictItemMapper.updateById(bean);
		}
		return sysDictItemMapper.insert(bean);
	}

}